-
Notifications
You must be signed in to change notification settings - Fork 7
Rewrite tests with mollusk #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
joncinque
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good! Just one little question on whether one of the stores is needed
| create_config_account( | ||
| &mut context, | ||
| &config_keypair, | ||
| vec![(pubkey, false), (pubkey, false), (pubkey, false)], // Dummy keys for account sizing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank goodness for removing this, it confused the crap out of me during the first review 😅
| let instruction = config_instruction::store(&config, true, keys.clone(), &my_config); | ||
| let result = mollusk.process_and_validate_instruction( | ||
| &instruction, | ||
| &[ | ||
| (config, config_account), | ||
| (signer0, AccountSharedData::default()), | ||
| ], | ||
| &[Check::success(), Check::compute_units(3_324)], | ||
| ); | ||
|
|
||
| // Use this for next invoke. | ||
| let updated_config_account = result.get_account(&config).unwrap().to_owned(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this part actually needed since you're storing the proper account data from the start?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically you're right that would also work, but to be extra sure I wanted to pipe the newly created config account state into the "update" instruction. The create_config_account helper uses the default value (uninitialized data) to space the account, and the first invoke sets it to MyConfig::new(42). This way we get to assert a valid transition from MyConfig::new(42) to MyConfig::new(84).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok great, the new change looks good!
This PR rewrites all program tests with Mollusk instead of
solana-program-test.